
import kafka from 'node-rdkafka'


var producer=new kafka.Producer({
    'metadata.broker.list':"localhost:9092"
})

producer.connect()

producer.on('ready',()=>{
    producer.produce(
        "acReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"contestInfo.permanent"
        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"contestInfo.upcoming"
        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"contestInfo.past"
        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"userRank",
            userName:"tourist",
            
        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"userRating",
            userName:"tourist",
            
        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"userSubmit",
            userName:"tourist",
            contestUrl:"https://atcoder.jp/contests/arc144"

        })),
        "test"
    )
    producer.produce(
        "accodeReq",
        null,
        Buffer.from(JSON.stringify({
            requestType:"userCompetitionHistory",
            userName:"tourist",
            contestUrl:"https://atcoder.jp/contests/arc144"

        })),
        "test"
    )
   

})
producer.setPollInterval(100)


producer.on("event.error",(err)=>{
    console.log(err)
})